# -*- coding: utf-8 -*-

from django import template
from django.template import Context
from django.template import Library
from django.template import Node
from widgets.forms import *
from blog.models import News
register = Library()

class WidgetBlogNode(Node):

    def __init__(self):
        pass
        
    def render(self, context):
        list = News.objects.all()[:5]
        title = 'Na blogu'

        t = template.loader.get_template('widgets/blogi.html')#taka tam przyjęta konwencja, plural=główny template

        return t.render(Context({'list': list, 'title':title, 'MEDIA_URL':context['MEDIA_URL'], }, autoescape=context.autoescape))


@register.tag
def widget_blog(parser, token):
    return WidgetBlogNode()
